package cn.zcscloud.mall.mbg.mapper;

import cn.zcscloud.mall.mbg.model.SmsFlashPromotionProductRelation;
import cn.zcscloud.mall.mbg.model.SmsFlashPromotionProductRelationExample;
import java.util.List;

import cn.zcscloud.mall.vo.SmsFlashPromotionProductVo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface SmsFlashPromotionProductRelationMapper extends BaseMapper<SmsFlashPromotionProductRelation> {
    @Select("SELECT\n" +
            "            r.id,\n" +
            "            r.flash_promotion_price,\n" +
            "            r.flash_promotion_count,\n" +
            "            r.flash_promotion_limit,\n" +
            "            r.flash_promotion_id,\n" +
            "            r.flash_promotion_session_id,\n" +
            "            r.product_id,\n" +
            "            r.sort,\n" +
            "            p.id p_id,\n" +
            "            p.`name` p_name,\n" +
            "            p.product_sn p_product_sn,\n" +
            "            p.price p_price,\n" +
            "            p.stock p_stock\n" +
            "        FROM\n" +
            "            sms_flash_promotion_product_relation r\n" +
            "            LEFT JOIN pms_product p ON r.product_id = p.id\n" +
            "        WHERE\n" +
            "            r.flash_promotion_id = #{flashPromotionId}\n" +
            "            AND r.flash_promotion_session_id = #{flashPromotionSessionId}\n" +
            "        ORDER BY r.sort DESC")
    public IPage<SmsFlashPromotionProductVo> getListPage(Page<SmsFlashPromotionProductVo> page, Long flashPromotionId, Long flashPromotionSessionId);
}